<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h2>firstName: {{firstName}}</h2>
      <h2>lastName: {{lastName}}</h2>
      <h2>fullName: {{fullName}}</h2>
      <hr />
      <h2>fullNameFn: {{fullNameFn()}}</h2>
      <h2>fullNameFn: {{fullNameFn()}}</h2>
    </div>
    <script type="module">
      import {
        createApp,
        ref,
        reactive,
        nextTick,
        computed,
      } from "./vue.esm-browser.js";
      const app = createApp({
        setup() {
          const firstName = ref("chen");
          const lastName = ref("jack");
          // 响应
          const fullName = computed(() => {
            return `${Math.ceil(Math.random() * 10000)}-${lastName.value} ${
              firstName.value
            }`;
          });
          const fullNameFn = function () {
            return `${Math.ceil(Math.random() * 10000)}-${lastName.value} ${
              firstName.value
            }`;
          };
          return {
            firstName,
            lastName,
            fullName,
            fullNameFn,
          };
        },
      });
      app.mount("#app"); //挂载
    </script>
  </body>
</html>
